SPL provides multiple iterator classes that provide iterative access, filtering data, caching results, and controlling paging. , because PHP is always growing, I try to list all of the iteration classes in SPL. Some of the following iterator classes
One: What is an iteratorThe process of iterating through a linked list or an element in an array in a uniform way is called iterative traversal, which we call an iterator.II: Arrayiterator iterators1:iterator interfaceIterators in PHP are defined by
Php spl can be seen in many frameworks and MVC. php spl accounts for a large proportion in many practical applications.
Two-Way linked list
Push (1); $ obj-> push (2); $ obj-> push (3); $ obj-> unshift (10 ); // unshifit occupies the last
PHPSPL can be seen in many frameworks and MVC. PHPSPL accounts for a large proportion in many practical applications. php spl can be seen in many frameworks and MVC, php spl accounts for a large proportion in many practical applications.
Two-Way
Arrayobject is to convert an array of arrays of objects, this article mainly to share with you arrayobject instructions, I hope to help everyone.
code example
$arrayobject = new Arrayobject ($array);//Constructs a Arrayobject object for ($iterator =
PHP SPL can be seen in many frameworks and MVC, and PHP SPL accounts for a large proportion of the actual applications. Doubly linked list push (1), $obj->push (2), $obj->push (3); $obj->unshift (10); Unshifit takes the last element of the
PHP SPL can be seen in many frameworks and MVC, and PHP SPL accounts for a large proportion of the actual applications.
Doubly linked list
push (1), $obj->push (2), $obj->push (3); $obj->unshift (Ten) ; Unshifit Replace the header $obj->rewind ()
As usual, two for personal use of "small" things, to point to improve the opinion of more points, pure access to the inspection manager should be deleted paste, hey
Note: Because it is for personal use, the incoming basic is formal format, so did
There are several predefined interfaces in PHP, more commonly used four interfaces (iteratoraggregate (aggregated aggregate iterator iterator),countable, Arrayaccess,iterator) to give you a detailed introduction.
Iteratoraggregate (aggregated
Introduction in PHP has several predefined interfaces, but also useful iteratoraggregate (aggregated aggregate iterator iterator) Iteratoraggregate extends traversable {Abstract public traversable getiterator (void)} This interface implements a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.